package com.itheima.controller.backend;

import com.itheima.common.entity.Result;
import com.itheima.service.backend.impl.SpringSecurityUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录控制层
 */
@RestController
@RequestMapping( "")
@Slf4j
public class LoginControler {

    @Autowired
    private SpringSecurityUserService springSecurityUserService;

    /**
     * 登录
     * @param username
     * @return
     */
    @GetMapping("/login")
    public Result login(@RequestParam(value ="username") String username) {
        log.info("用户登录:{}", username);
        return new Result(true, "登录成功",springSecurityUserService.loadUserByUsername(username));
    }
}
